/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package muddb.entities;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


/**
 *
 * @author keith
 */
@Entity
@Table( name = "events" )
public class EventLog implements Serializable {
  private Integer eventId;
  private Date eventTs;
  private String eventMessage;


  public EventLog() {
  }


  public EventLog( String eventMessage ) {
    this.eventTs = Calendar.getInstance().getTime();
    this.eventMessage = eventMessage;
  }


  @Id
  @Column( name = "evnt_id", nullable=false )
  @GeneratedValue( strategy = GenerationType.SEQUENCE )
  public Integer getEventId() {
    return eventId;
  }


  public void setEventId( Integer eventId ) {
    this.eventId = eventId;
  }

  @Column( name = "evnt_ts", nullable=false )
  @Temporal( TemporalType.TIMESTAMP )
  public Date getEventTs() {
    return eventTs;
  }


  public void setEventTs( Date eventTs ) {
    this.eventTs = eventTs;
  }


  @Column( name = "evnt_msg", length=255, nullable=false )
  public String getEventMessage() {
    return eventMessage;
  }


  public void setEventMessage( String eventMessage ) {
    this.eventMessage = eventMessage;
  }


  @Override
  public boolean equals( Object obj ) {
    if ( obj == null ) {
      return false;
    }
    if ( getClass() != obj.getClass() ) {
      return false;
    }
    final EventLog other = (EventLog) obj;
    if ( this.eventId != other.eventId && ( this.eventId == null || !this.eventId.equals( other.eventId ) ) ) {
      return false;
    }
    return true;
  }

  
  @Override
  public int hashCode() {
    int hash = 5;
    hash = 89 * hash + ( this.eventId != null ? this.eventId.hashCode() : 0 );
    return hash;
  }


  @Override
  public String toString() {
    return "muddb.entities.EventLog[eventId=" + eventId + "]";
  }


}
